import os
import commands

def cmdtxt(pyscript,styleimg,contentimg,modelname,gpuid):
    s = '-s ' + styleimg
    c = '-c ' + contentimg
    m = '-m ' + modelname
    g = '-g ' + str(gpuid)
    action='python'
    cmdlist=[action,pyscript,s,c,m,g]
    jnt=' '
    cmdconent=jnt.join(cmdlist)
    return cmdconent

def execute_style_transfer(pyscript,styleimg,contentimg,modelname,gpuid):
    execmd=cmdtxt(pyscript,styleimg,contentimg,modelname,gpuid)
    print execmd
    status=os.system(execmd)
    # (status,output)=commands.getstatusoutput(execmd)
    print 'EXED...'
    if status == 0 :
        print 'Well Done!'
    else:
        print 'Boom!'

# pyscript='F:/style-transfer/style-transfer-master/style.py'
# BDR=(os.path.dirname(os.path.abspath(__file__))).replace('\\','/')
# pyscript = BDR + '/' + 'style.py'
# styleimg='F:/style-transfer/style-transfer-master/images/style/starry_night.jpg'
# contentimg='F:/style-transfer/style-transfer-master/images/content/xiongjiang.jpg'
# modelname='googlenet'
# execute_style_transfer(pyscript,styleimg,contentimg,modelname,-1)